package cn.bbs.ba.session;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import cn.bbs.ba.base.BaseDto;
import cn.bbs.ba.system.SystemKey;

public class SessionFactoryZ {

	public static Log _log = LogFactory.getLog(SessionFactoryZ.class);
	
    /**  */
    private static ThreadLocal<Map<String, BaseDto>> _connectionMapHolder = new ThreadLocal<Map<String, BaseDto>>() {
        protected Map<String, BaseDto> initialValue() {
            return new HashMap<String, BaseDto>();
        }
    };
    
    /**
     * @param pkey SystemKey
     * @return Connection sqll��
     */
    public static BaseDto getBaseDto(final SystemKey pkey) {
        Map<String, BaseDto> cmap = (Map<String, BaseDto>)_connectionMapHolder.get();
        BaseDto ret_conn = (BaseDto)cmap.get(pkey.name());
        if (null == ret_conn) {
            ret_conn = getNewBaseDto(pkey);
            cmap.put(pkey.name(), ret_conn);
        }
        return ret_conn;	
    }

    /**
     * ��bһ����l��
     * @param pkey SystemKey
     * @return Connection ��bһ����l��
     */
    private static BaseDto getNewBaseDto(final SystemKey pkey) {
    	BaseDto ret_conn = new BaseDto();
        return ret_conn;
    }
}
